package com.li.service.impl;

import com.li.exception.NotFondException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.li.domain.SystemAddress;
import com.li.mapper.SystemAddressMapper;
import com.li.service.SystemAddressService;
@Service
public class SystemAddressServiceImpl extends ServiceImpl<SystemAddressMapper, SystemAddress> implements SystemAddressService{

    @Autowired
    private SystemAddressMapper systemAddressMapper;

    @Override
    public Integer listPageSystemAddressCount(SystemAddress systemAddress) {
        return systemAddressMapper.listPageSystemAddressCount(systemAddress);
    }

    @Override
    public List<SystemAddress> listPageSystemAddress(SystemAddress systemAddress, Integer page, Integer limit) {
        Integer indexPage=(page-1)*limit;
        return systemAddressMapper.listPageSystemAddress(systemAddress,indexPage,limit);
    }

    @Override
    public Integer addSystemAddress(SystemAddress systemAddress) {
        if ("".equals(systemAddress.getSysPath())){
            new NotFondException("文件路径为空");
            return 0;
        }
        systemAddress.setCreateTime(new Date());
        return systemAddressMapper.insert(systemAddress);
    }

    @Override
    public Integer updateSystemAddress(SystemAddress systemAddress) {
        if ("".equals(systemAddress.getSysPath())){
            new NotFondException("文件路径为空");
            return 0;
        }
        systemAddress.setUpdateTime(new Date());
        return systemAddressMapper.updateById(systemAddress);
    }
}
